define(['jquery', 'bootstrap', 'frontend', 'form', 'template'], function ($, undefined, Frontend, Form, Template) {
    var validatoroptions = {
        invalid: function (form, errors) {
            $.each(errors, function (i, j) {
                Layer.msg(j);
            });
        }
    };
    var Controller = {
        wxexec: function () {
            $("#weixin-form").data("validator-options", validatoroptions);
            Form.api.bindevent($("#weixin-form"), function (data, ret) {
                setTimeout(function () {
                    location.href = ret.url ? ret.url : "/index/index/wxexec";
                }, 1000);
            });
        },
        test: function () {
            $(".types li").click(function(){
                $(".types li").each(function(){
                    $(this).attr('class','');
                });
                $(this).attr('class','active');
            });
            if (Config.V == 'test_pay_pc') {
                $(document).on("click", ".immediate_pay", function () {
                    var value = $(".types").find('.active').attr('value');
                    Fast.api.ajax({
                        url: "/index/index/pay",
                        type: "post",
                        data: {'type':value},
                    }, function (data, ret) {
                        layer.open({type:1,content:ret.data});
                        return false;
                    });
                });
            }
            if (Config.C.msg && Config.V !== 'test_pay_pc') {
                Layer.alert(Config.C.msg,function () {
                    window.location.href='/index/index/test';
                });
            }
        },

    };
    return Controller;
});

function pay(type){
    Fast.api.ajax({
        url: "/index/index/pay",
        type: "post",
        data: {'type':type},
    }, function (data, ret) {
        layer.open({type:1,content:ret.data});
        return false;
    });
}